#include <iostream> 
#include <algorithm>
using namespace std;
const int N = 110, INF = 1e9;
int a[N][N];
int f[N][N];
int n;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            scanf("%d", &a[i][j]);
        }
    }

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (i == 1 && j == 1)
            {
                f[i][j] = a[i][j];
            }
            else
            {
                f[i][j] = INF;
                if (i > 1)
                {
                    f[i][j] = min(f[i - 1][j] + a[i][j], f[i][j]);
                }
                if (j > 1)
                {
                    f[i][j] = min(f[i][j - 1] + a[i][j], f[i][j]);
                }
            }
        }
    }
    printf("%d", f[n][n]);
    return 0;
}